/**
 * @date 2016/5/18
 * @author speed
 * 游戏全局变量
 */
class App {
    public static ProtoConfig :any = null ;
    public static ProtoFile :any = null ;
    public static GlobalData :any = null ;  //全局配置文件
    public static IMIE:string="";
    public static NetAvailable:boolean=false;

    public static pkgVersion:string="1.0";
    public static version:string="1.0.02";
    public static gameIsInBack:boolean=false;
    public static root: eui.UILayer;
  
    public static soundStorageKey:string = "soundToggle";

    public static saveItem(key:string,value:string):void{
        egret.localStorage.setItem(key,value);
    }

    public static getItem(key):string{
        return egret.localStorage.getItem(key) || null;
    }

    public static initData(){
        // NetDataHandler.init();
        // // App.Http.initServer("");
        // App.Socket.initServer(GameGlobal.ip,GameGlobal.port,new UTFMsgByJson());
        // App.GlobalData  = GameGlobal;
        //App.ProtoConfig = RES.getRes(App.GlobalData.ProtoConfig);
        //App.ProtoFile   = dcodeIO.ProtoBuf.loadProto(RES.getRes(App.GlobalData.ProtoFile));
        App.DebugUtils.isOpen(true);
        
    }

    /**
     * 对象池管理
     */
    public static get ObjectPool():ObjectPool {
        return  new ObjectPool();
    }
    /**
     * 场景管理器
     * UI层管理
     */
    public static get UIManager():UIManager {
        return UIManager.instance ;
    }
    /**
     * 请求服务器使用的用户标识
     * @type {string}
     */
    public static ProxyUserFlag: string = "";

     /**
     * 模块管理类
     * @type {ControllerManager}
     */
    public static get ControllerManager(): ControllerManager {
        return ControllerManager.getInstance();
    }

    /**
     * View管理类
     * @type {ViewManager}
     */
    public static get ViewManager(): ViewManager {
        return ViewManager.getInstance();
    }
    /**
     * Http请求
     * @type {Http}
     */
    public static get Http():Http {
        return Http.getInstance();
    }

     /**
     * md5加密工具
     */
    public static get md5():md5 {
        return md5.getInstance();
    }

    /**
     * Socket请求
     * @type {null}
     */
    public static get Socket():Socket {
        return Socket.getInstance();
    }

    


    /**
     * 调试工具
     * @type {DebugUtils}
     */
    public static get DebugUtils():DebugUtils {
        return DebugUtils.getInstance();
    }

   

    /**
     * 统一的计时器和帧刷管理类
     * @type {TimerManager}
     */
    public static get TimerManager():TimerManager {
        return TimerManager.getInstance();
    }

    /**
     * 日期工具类
     * @type {DateUtils}
     */
    public static get DateUtils():DateUtils {
        return DateUtils.getInstance();
    }

    /**
     * 数学计算工具类
     * @type {MathUtils}
     */
    public static get MathUtils():MathUtils {
        return MathUtils.getInstance();
    }

    /**
     * 随机数工具类
     * @type {RandomUtils}
     */
    public static get RandomUtils():RandomUtils {
        return RandomUtils.getInstance();
    }

    /**
     * 显示对象工具类
     * @type {DisplayUtils}
     */
    public static get DisplayUtils():DisplayUtils {
        return DisplayUtils.getInstance();
    }

    /**
     * Stage操作相关工具类
     */
    public static get StageUtils():StageUtils {
        return StageUtils.getInstance();
    }

    /**
     * Effect工具类
     */
    public static get EffectUtils():EffectUtils {
        return EffectUtils.getInstance();
    }

    /**
     * 字符串工具类
     */
    public static get StringUtils():StringUtils {
        return StringUtils.getInstance();
    }

    /**
     * 通过工具类
     */
    public static get CommonUtils():CommonUtils {
        return CommonUtils.getInstance();
    }


    /**
     * 引擎扩展类
     */
    public static get EgretExpandUtils():EgretExpandUtils {
        return EgretExpandUtils.getInstance();
    }


    /**
     * 震动类
     */
    public static get ShockUtils():ShockUtils {
        return ShockUtils.getInstance();
    }

    /**
     * 资源加载工具类
     */
    public static get ResourceUtils():ResourceUtils {
        return ResourceUtils.getInstance();
    }

    /**
     * TextFlow
     */
    public static get TextFlowMaker():TextFlowMaker {
        return TextFlowMaker.getInstance();
    }

    
    /**
     * 消息通知中心
     */
    private static _notificationCenter: MessageCenter;

    public static get NotificationCenter(): MessageCenter {
        if (App._notificationCenter == null) {
            App._notificationCenter = new MessageCenter(1);
        }
        return App._notificationCenter;
    }

    /**
     * 消息广播中心
     */
    public static get NotificationManager() :NotificationManager {
        return NotificationManager.instance ;
    }

    /**
     * 分帧处理类
     * @returns {any}
     * @constructor
     */
    public static get DelayOptManager():DelayOptManager {
        return DelayOptManager.getInstance();
    }
    

    public static get DragonBonesFactory() :DragonBonesFactory{
        return DragonBonesFactory.getInstance() ;
    }
}
